//============================================================================
// Name        : Hal.cpp
// Author      : Cristian Gonzalo Gary Bufadel
// Version     :
// Copyright   : 
// Description :
//============================================================================

using namespace std;

#include <Logger.h>
#include <AmbienteWorker.h>
#include <Nodo.h>
#include <Worker.h>
#include <Print.h>
#include <Data.h>


#if defined(__DATE__) && defined(__TIME__)
static const char HAL_BUILT[] = __DATE__ " " __TIME__;
#else
static const char HAL_BUILT[] = "Unknown";
#endif

#define OS "Linux"

#define __HAL__            0
#define __HAL_MINOR__      01
#define __HAL_PATCHLEVEL__ 0
#define CC "gcc"

#define HAL_VERSION (__HAL__ * 10000 \
                                __HAL_MINOR__ * 100 \
                                __HAL_PATCHLEVEL__)
#define VERSION "0.02.0"

#define RUN 1
#define NO_RUN 0

using namespace TipoDato;

int Logger::init_time = time(NULL);

void hal_version(void) {
	printf("HAL %i.%i.%i\n", __HAL__, __HAL_MINOR__, __HAL_PATCHLEVEL__);
	printf("Built : %s (%s %i.%i.%i)\n", HAL_BUILT, CC, __GNUC__,
			__GNUC_MINOR__, __GNUC_PATCHLEVEL__);
	printf("Home  : http://www.seginus.cl\n");
	fflush(stdout);
}

int main(void) {

	hal_version();

	AmbienteWorker* a = new AmbienteWorker(40,40);

	Worker* worker1 = new Worker(1,"1"," Worker 1");
	Worker* worker2 = new Worker(2,"2"," Worker 2");
	Worker* worker3 = new Worker(3,"3"," Worker 3");
	Worker* worker4 = new Worker(4,"4"," Worker 4");
	Worker* worker5 = new Worker(5,"5"," Worker 5");
	Worker* worker6 = new Worker(6,"6"," Worker 6");
	Worker* worker7 = new Worker(7,"7"," Worker 7");
	Worker* worker8 = new Worker(8,"8"," Worker 8");
	Worker* worker9 = new Worker(9,"9"," Worker 9");
	Worker* worker10 = new Worker(10,"10"," Worker 10");
	Worker* worker11 = new Worker(11,"11"," Worker 11");
	Worker* worker12 = new Worker(12,"12"," Worker 12");

	worker1->setAmbiente(a);
	worker2->setAmbiente(a);
	worker3->setAmbiente(a);
	worker4->setAmbiente(a);
	worker5->setAmbiente(a);
	worker6->setAmbiente(a);
	worker7->setAmbiente(a);
	worker8->setAmbiente(a);
	worker9->setAmbiente(a);
	worker10->setAmbiente(a);
	worker11->setAmbiente(a);
	worker12->setAmbiente(a);

	a->setNodoAndRun(15,1,worker2);
	a->setNodoAndRun(4,12,worker3);
	a->setNodoAndRun(1,1,worker4);
	a->setNodoAndRun(1,5,worker5);
	a->setNodoAndRun(5,17,worker6);
	a->setNodoAndRun(3,13,worker7);
	a->setNodoAndRun(5,16,worker8);
	a->setNodoAndRun(12,19,worker9);
	a->setNodoAndRun(15,12,worker10);
	a->setNodoAndRun(11,6,worker11);
	a->setNodoAndRun(1,6,worker12);


	Logger* logger = new Logger();


 Print* print = new Print();

//
//while(1){
//
//	printf("\r");
//	print->printConsola(a);
//	printf("\033[40A");
//
//	fflush(stdout);
//	usleep(1000);
//}

	delete logger;
	delete a;
	delete worker1;
	delete print;
}
